<!--
 * @Author: 杨光辉(GerhardYang)
 * @Date: 2021-09-09 14:26:06
 * @LastEditors: 杨光辉(GerhardYang)
 * @LastEditTime: 2021-09-10 08:39:56
 * @Description: file content
 * @Copyright: 超图软件华中平台客户中心 (SuperMap Software Co., Ltd. -Central China Platform)
-->
<template>
  <div>
    <a-modal v-model="visible" on-ok="handleOk" :zIndex="9999">
      <p slot="title">{{ title }}</p>
      <template slot="footer">
        <!-- <a-button key="back" @click="handleCancel"> Return </a-button> -->
        <a-button key="submit" type="primary" @click="handleOk">
          <a-icon type="download" />下载
        </a-button>
      </template>
      <div align="center">
        <img
          style="max-width: 500px; max-height: 300px"
          :src="imgUrl"
          onerror="javascript:this.src='images/error.png'"
        />
      </div>
    </a-modal>
  </div>
</template>
<script>
import { download } from "@/utils/downloadImg.js";

export default {
  data() {
    return {
      visible: false,
      title: null,
      imgUrl: null,
    };
  },

  methods: {
    buildData(obj) {
      this.title = obj.title;
      this.imgUrl = obj.imgUrl;
      this.visible = true;
    },

    handleOk() {
      download(this.imgUrl, this.title);
      this.visible = false;
    },
    handleCancel() {
      this.visible = false;
    },
  },
};
</script>
